package com.yzt.minemodule.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.yzt.zhuju.network.entity.mine.wallet.WalletBean;
import com.yzt.minemodule.R;
import com.yzt.plugin_imageloader.ImageLoadUtil;

import org.jetbrains.annotations.NotNull;

/**
 * 作者：bobwang
 * 创建时间：2023-11-17 09:56:03
 * 描述：
 */
public class WalletListAdapter extends BaseQuickAdapter<WalletBean, BaseViewHolder> implements LoadMoreModule {

    private int type;

    /**
     * 1 糖币 2 收益 3 历史
     */
    public void setType(int type) {
        this.type = type;
    }

    public WalletListAdapter() {
        super(R.layout.item_wallet);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, WalletBean data) {

        if (data.isShowTitle()) {
            holder.setGone(R.id.ll_header, false);
            holder.setGone(R.id.ll_content, true);
            holder.setText(R.id.tv_title_time, data.getTitleDate());
            holder.setText(R.id.tv_title_desc, data.getTitleInfo());
        } else {
            holder.setGone(R.id.ll_header, true);
            holder.setGone(R.id.ll_content, false);
            // 背景头像
            ImageView header = holder.getView(R.id.img_avatar);
            ImageLoadUtil.loadAvatar(getContext(), data.getAvatar(), header, R.mipmap.icon_placeholder);
            if (type == 1) {
                //糖币明细类型 [ 1：充值，2：发红包，3：发礼物，4：红包退款 ]
                if (data.getCandyParticularsType() == 1) {
                    holder.setText(R.id.tv_title, data.getCandyParticularsTypeInfo());
                    holder.setText(R.id.tv_content, data.getParticularsDate());
                    holder.setText(R.id.tv_money, data.getCandyCoin());
                    Glide.with(getContext()).load(R.mipmap.icon_wallet_list_coin).into(header);
                } else if (data.getCandyParticularsType() == 2) {
                    holder.setText(R.id.tv_title, data.getCandyParticularsTypeInfo());
                    holder.setText(R.id.tv_content, data.getParticularsDate());
                    holder.setText(R.id.tv_money, data.getCandyCoin());
                    ImageLoadUtil.loadAvatar(getContext(), data.getAvatar(), header, R.mipmap.icon_placeholder);
                } else if (data.getCandyParticularsType() == 3) {
                    holder.setText(R.id.tv_title, data.getCandyParticularsTypeInfo() + " - " + data.getNickName());
                    holder.setText(R.id.tv_content, data.getParticularsDate());
                    holder.setText(R.id.tv_money, data.getCandyCoin());
                    ImageLoadUtil.loadAvatar(getContext(), data.getAvatar(), header, R.mipmap.icon_placeholder);
                } else if (data.getCandyParticularsType() == 4) {
                    holder.setText(R.id.tv_title, data.getCandyParticularsTypeInfo());
                    holder.setText(R.id.tv_content, data.getParticularsDate());
                    holder.setText(R.id.tv_money, data.getCandyCoin());
                    Glide.with(getContext()).load(R.mipmap.icon_wallet_list_coin).into(header);
                }
            } else if (type == 2) {
                holder.setText(R.id.tv_title, data.getCandyParticularsTypeInfo() + " - " + data.getNickName());
                holder.setText(R.id.tv_content, data.getParticularsDate());
                holder.setText(R.id.tv_money, data.getShowIncome());
                ImageLoadUtil.loadAvatar(getContext(), data.getAvatar(), header, R.mipmap.icon_placeholder);
            } else if (type == 3) {
                holder.setText(R.id.tv_title, data.getInfo());
                holder.setText(R.id.tv_content, data.getDate());
                holder.setText(R.id.tv_money, data.getAmount());
                Glide.with(getContext()).load(R.mipmap.icon_wallet_list_coin).into(header);
            }
        }
    }
}
